﻿using HR.Config;
using HR.Filters;
using HR.IService;
using HR.Models;
using Microsoft.AspNetCore.Mvc;

namespace HR.Controllers
{
    public class SalaryAdminSetController : Controller
    {
        private readonly ISalaryItemService isis;

        public SalaryAdminSetController(ISalaryItemService isis)
        {
            this.isis = isis;
        }
        [TypeFilter(typeof(RoleFilterAttribute))]
        public IActionResult Index()
        {
            return View();
        }
        [HttpGet]
        public async Task<IActionResult> SalaryAdminSetFill(int pgsize,int pgcurrent)
        {
            Paging<config_public_char> task = await isis.SalaryItemFill(pgsize, pgcurrent);
            return Json(task);
        }
        [HttpPost]
        public async Task<IActionResult> SalaryAdminAdd([FromBody]config_public_char cpc)
        {
            int res = await isis.SalaryItemAdd(cpc);
            return Json(res);
        }
        [HttpPost]
        public async Task<IActionResult> SalaryAdminUpdate([FromBody]config_public_char cpc)
        {
            int res = await isis.SalaryItemUpdate(cpc);
            return Json(res);
        }
        [HttpDelete]
        public async Task<IActionResult> SalaryAdminDelete(short pbc_id)
        {
            int res = await isis.SalaryItemDelete(pbc_id);
            return Json(res);
        }
    }
}
